package cst.a810lw.zyfypt_810lw.Fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

import cst.a810lw.zyfypt_810lw.Adapter.VideoAdapter;
import cst.a810lw.zyfypt_810lw.Bean.VideoBean;
import cst.a810lw.zyfypt_810lw.Listener.AmicoolListener;
import cst.a810lw.zyfypt_810lw.Model.ResModel;
import cst.a810lw.zyfypt_810lw.R;

/**
 * A simple {@link Fragment} subclass.
 */
public class VideoFragment extends Fragment {
    private RecyclerView recyclerView;
    private VideoAdapter adapter;
    private List<VideoBean> list;
    private RecyclerView.LayoutManager layoutManager;
    private AmicoolListener<List<VideoBean>> listener;
    private ResModel model;

    public VideoFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view=inflater.inflate(R.layout.fragment_video, container, false);
        recyclerView=(RecyclerView)view.findViewById(R.id.video_rec);
        adapter =new VideoAdapter(getActivity());
        list=new ArrayList<VideoBean>();
        layoutManager=new LinearLayoutManager(getActivity());
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(adapter);
        listener=new AmicoolListener<List<VideoBean>>() {
            @Override
            public void onResponse(List<VideoBean> l) {
                adapter.setList(l);
            }

            @Override
            public void onFail(String msg) {

            }
        };
        model=new ResModel("gson");
        model.getList("video",1,listener);
        return view;
    }
}
